package com.irdstudio.efp.nls.api.rest.sed;

import java.util.List;
import java.util.Map;

import com.irdstudio.basic.framework.core.constant.DataRuleType;
import com.irdstudio.basic.framework.core.constant.PubConstant;
import com.irdstudio.efp.loan.service.vo.AccLoanVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.irdstudio.basic.framework.core.constant.ResponseData;
import com.irdstudio.basic.framework.web.controller.AbstractController;
import com.irdstudio.efp.e4a.service.facade.SRoleDataRuleService;
import com.irdstudio.efp.rule.service.facade.TaxAllInfoService;
import com.irdstudio.efp.rule.service.vo.TaxBasicInfoVO;
import com.irdstudio.efp.rule.service.vo.TaxInfoMainVO;


/**
 * Controller：纳税基本信息表
 * @author ligm
 * @date 2019-04-29 
 */
@RestController
@RequestMapping("/api")
public class TaxInfoController extends AbstractController {
	
	//纳税信息服务
	@Autowired
	private TaxAllInfoService taxAllInfoService;
    
	@Autowired
	@Qualifier("sRoleDataRuleService")
	private SRoleDataRuleService sRoleDataRuleService;

    
	@RequestMapping(value="/tax/basic/infos", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<TaxInfoMainVO>> queryTaxBasicInfoAll(@RequestBody TaxInfoMainVO vo) {
		List<TaxInfoMainVO> outputVo = null;
		Map<String,String> dataRuleTypeMap = sRoleDataRuleService.getDataRuleType(httpRequest.getRequestURI(), getUserRoles());
		vo.setPrdCodebyBaseInfo(dataRuleTypeMap == null ? null:dataRuleTypeMap.get(PubConstant.PRD_CODE));
		DataRuleType dataRuleType = DataRuleType.getDataRuleType(dataRuleTypeMap == null ? null:dataRuleTypeMap.get(PubConstant.PERMIS_TYPE));
		setUserInfoToVO(vo);
		outputVo = taxAllInfoService.queryAllInfoLimit(vo, dataRuleType.getValue());
		return getResponseData(outputVo);
	}

	@RequestMapping(value="/tax/basic/info/crdt", method=RequestMethod.POST)
	public @ResponseBody ResponseData<TaxBasicInfoVO> queryByCrdtAppFlowNo(@RequestBody TaxBasicInfoVO vo) {

		TaxBasicInfoVO outputVo = null;
		setUserInfoToVO(vo);

        // 直接查询数据
		outputVo = taxAllInfoService.queryByCrdtAppFlowNo(vo);
		return getResponseData(outputVo);	
	}
}
